package com.wn.controller;


import com.wn.entity.Manager;
import com.wn.entity.ResponseEntity;
import com.wn.service.ManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("/rbac_manager")
public class ManagerController {
    @Autowired
    ManagerService managerService;

    @PostMapping("crud")
    public ResponseEntity addOne(@RequestBody Manager manager) {
        return managerService.addOne(manager);

    }

    @DeleteMapping("crud/{id}")
    public ResponseEntity deleteOne(@PathVariable int id) {
        return managerService.deleteOne(id);
    }

    @PutMapping("crud")
    public ResponseEntity update(@RequestBody Manager manager) {
        return managerService.update(manager);
    }

    @GetMapping("crud/{currentPage}/{pageSize}")
    public ResponseEntity findAll(@PathVariable int currentPage, @PathVariable int pageSize) {

        return managerService.findAll(currentPage, pageSize);
    }
    @PostMapping("findAll")
    public ResponseEntity findAll() {

        return managerService.findAll();
    }
    @GetMapping("crud/search")
    public ResponseEntity findByCondition(@RequestBody Manager manager) {

//        return managerService.findByCondition(manager);
        return null;
    }
}


